import {
	httpRequest,
	dalImg
} from '@/utils/tools.js'


// 示例
/**
 * 用户登录
 */
export const UserLoginAPI = (data) => {
	return httpRequest('/auth/login', data, "POST")
}


/**
 * 用户注册
 */
export const UserRegAPI = (data) => {
	return httpRequest('/auth/reg', data, "POST")
}
//轮播图前台
///illnesses/categories
export const getIllnesssAPIs = (data) => {
	return httpRequest('/illnesses/categories', data, 'GET')
}
export const getMedicineAPIs = (data) => {
	return httpRequest('/medicines', data, 'GET')
}
//获取分类
export const getMedicineCategoryAPI = () => {
	return httpRequest('/medicines/categories', 'GET')
}
//根据分类获取数据
export const getMedicineAPIIs = (category, data) => {
	return httpRequest(`/medicines?category=${category}`, data, 'GET')
}
//详情页
export const getMedicineAPIId = (id) => {
	return httpRequest(`/medicines/${id}`, 'GET')
}
//搜索商品
export const getIllnesssAPI = (data) => {
	return httpRequest('/medicines', data, 'GET')
}
//加入购物车
export const addShopCartAPI = (data) => {
	return httpRequest('/members/shop_carts', data, 'POST')
}
//获取购物车数据
export const getShopCartAPI = () => {
	return httpRequest('/members/shop_carts', 'GET')
}

//多选删除/members/shop carts
export const deleteShopCartAPI = (id) => {
	return httpRequest(`/members/shop_carts?id=${id}`, {}, 'DELETE')
}
//获取订单详情
///members/orders/{id}
export const huoqudingdanAPI=(id)=>{
	return httpRequest(`/members/orders/${id}`,"GET")
}
//提交订单/members/orders
export const tijiaodingdanAPI=(data)=>{
	return httpRequest('/members/orders',data,'POST')
}



/**
 * 获取用户信息
 */
export const GetUserInfoAPI = () => {
	return httpRequest('/members/info', {}, "GET")
}

/**
 * 修改用户信息
 */
export const EditUserInfoAPI = (data) => {
	return httpRequest('/members/update_info', data, "PUT")
}


/**
 * 获取收货地址
 */
export const GetUserAddressAPI = (id = "") => {
	return httpRequest('/members/addresses' + id, {}, "GET")
}

/**
 * 新建收货地址
 */
export const AddUserAddressAPI = (data) => {
	return httpRequest('/members/addresses', data, "POST")
}


/**
 * 修改收货地址
 */
export const EditUserAddressAPI = (id, data) => {
	return httpRequest('/members/addresses/' + id, data, "PUT")
}


/**
 * 删除收货地址
 */
export const DeleteUserAddressAPI = (id) => {
	return httpRequest(`/members/addresses?id=${id}`, {}, "DELETE")
}

/**
 * 获取文章信息列表
 */
export const GetArticlesListAPI = (per = 5, page = 1, keyword = "") => {
	return httpRequest(`/articles?per=${per}&page=${page}&keyword=${keyword}`, {}, "GET")
}


/**
 * 获取文章分类信息列表
 */
export const GetArticlesCategoriesListAPI = () => {
	return httpRequest(`/articles/categories`, {}, "GET")
}


/**
 * 获取订单信息列表
 */
export const GetorderListAPI = (status =-1,end =-1,payed =-1) => {
	return httpRequest(`/members/orders?status=${status}&end=${end}&payed=${payed}`, {}, "GET")
}

/**
 * 删除订单信息列表
 */
export const DeleteOrderListAPI = (id) => {
	return httpRequest(`/members/orders?id=${id}`, {}, "DELETE")
}

/**
 * 查看订单详情
 */
export const GetOrderOneAPI = (id) => {
	return httpRequest(`/members/orders?id=${id}`, {}, "GET")
}